/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mylhyl.circledialog.sample;

import com.airbnb.lottie.L;
import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.value.LottieAnimationViewData;
import com.mylhyl.circledialog.BaseCircleDialog;
import com.mylhyl.circledialog.ConstandCodes;
import com.mylhyl.circledialog.ViewConvertListener;
import com.mylhyl.circledialog.ViewHolder;
import com.mylhyl.circledialog.sample.model.ListCheckEntry;
import com.mylhyl.circledialog.sample.provider.AdPageProvider;
import com.mylhyl.circledialog.sample.provider.RvAdapterProvider;
import com.mylhyl.circledialog.sample.provider.RvListChooseProvider;
import com.mylhyl.circledialog.sample.provider.RvListProvider;
import com.mylhyl.circledialog.sample.provider.SampleProvider;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.animation.Animator;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.ListContainer;
import ohos.agp.components.PageSlider;
import ohos.agp.components.PageSliderIndicator;
import ohos.agp.components.ProgressBar;
import ohos.agp.components.TableLayoutManager;
import ohos.agp.components.Text;
import ohos.agp.components.TextField;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.window.dialog.BaseDialog;
import ohos.agp.window.dialog.ToastDialog;
import ohos.agp.window.service.WindowManager;
import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner;
import ohos.utils.IntervalTimer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import static ohos.agp.animation.Animator.INFINITE;

/**
 * FunItem
 *
 * @since 2021-07-21
 */
public class MainAbility extends Ability {
    private static final int DURATION = 400;
    private static final int DURATION2 = 300;
    private static final int DURATION3 = 800;
    private static final int DURATION4 = 100;
    private static final int DELAY = 50;
    private static final int DELAY_TIME = 3000;
    private static final int INTERVAL = 1000;
    private static final int MOVE_Y = 1000;
    private static final int MOVE_X = 10;
    private static final int TOTAL_INTERVAL = 30;
    private static final int ROTATE = 360;
    private static final int RED = 255;
    private static final int GREEN = 64;
    private static final int BLUE = 129;
    private static final int RGB = 122;
    private static final int LOOPED_COUNT = 5;
    private static final int VICE_PROGRESS = 10;
    private static final int TOTAL_TIME = 10;
    private static final int PERCENT = 100;
    private static final int LENGTH = 10;
    private static final int LIST_SIZE = 4;
    private static final int LIST_SIZE2 = 11;
    private static final int OFFSET = 20;
    private static final int REPEAT_COUNT = -1;

    private static final int COLUMN = 2;
    private static final int POS2 = 2;
    private static final int POS3 = 3;
    private static final int POS4 = 4;
    private static final int POS5 = 5;
    private static final int POS6 = 6;
    private static final int POS7 = 7;
    private static final int POS8 = 8;
    private static final int POS9 = 9;
    private static final int POS10 = 10;
    private static final int POS11 = 11;
    private static final int POS12 = 12;
    private static final int POS13 = 13;
    private static final int POS14 = 14;
    private static final int POS15 = 15;
    private static final int POS16 = 16;
    private static final int POS17 = 17;
    private static final int POS18 = 18;
    private static final int POS19 = 19;
    private static final int POS20 = 20;
    private static final int POS21 = 21;
    private static final int POS22 = 22;
    private static final int POS23 = 23;
    private static final int POS24 = 24;
    private static final int POS25 = 25;

    private BaseDialog dialog;
    private Text showToast;
    private ToastDialog toast;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        WindowManager.getInstance().getTopWindow().get()
                .setStatusBarColor(Color.getIntColor("#3F51B5"));
        super.setUIContent(ResourceTable.Layout_ability_main);
        initViews();
    }

    private void initViews() {
        ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_listContainer);
        List<FunItem> listData = Arrays.asList(FunItem.values());
        SampleProvider provider = new SampleProvider(this, listData);
        listContainer.setItemProvider(provider);
        TableLayoutManager layoutManager = new TableLayoutManager();
        layoutManager.setColumnCount(COLUMN);
        listContainer.setLayoutManager(layoutManager);
        listContainer.setLongClickable(false);
        listContainer.setItemClickedListener((listContainer1, component, pos, l) -> {
            showVariousDialog(pos);
        });
    }

    private void showVariousDialog(int pos) {
        switch (pos) {
            case 0:
                startAbility(MainAbility.this, FgtAbility.class.getName());
                break;
            case 1:
                showTipsDialog();
                break;
            case POS2:
                showIdentificationDialog();
                break;
            case POS3:
                showPortraitDialog();
                break;
            case POS4:
                showInputDialog();
                break;
            case POS5:
                showProgressDialog();
                break;
            case POS6:
                showWaittingDialog();
                break;
            case POS7:
                showRewaitingDialog();
                break;
            case POS8:
                showDynamicDialog();
                break;
            case POS9:
                showDiyDialog();
                break;
            case POS10:
                showCountDownDialog(); // 倒计时
                break;
            case POS11:
                showThreeButtonDialog(); // 三个按钮
                break;
            case POS12: // 自定义复选Adapter
                showRvListMulChoose(true);
                break;
            case POS13: // Rv换头像
                showRvImage("Rv换头像", "副标题：请从以下中选择照片的方式进行提交");
                break;
            default:
                break;
        }
        showVariousDialog2(pos);
    }

    private void showVariousDialog2(int pos) {
        switch (pos) {
            case POS14: // 自定义RvAdapter
                showRvAdapter();
                break;
            case POS15: // 自定义单选
                showRvListSingleChoose(false);
                break;
            case POS16: // 自定义内容视图
                showContentImg();
                break;
            case POS17: // lottie动画框
                showLottieAnimator();
                break;
            case POS18: // 仿微博分享
                showWeiboShare();
                break;
            case POS19: // RvVertical
                showList(true);
                break;
            case POS20: // RvHorizontal
                showList(false);
                break;
            case POS21:
                showAdwithoutX();
                break;
            case POS22:
                showAdBottomX();
                break;
            case POS23:
                showAdTopX();
                break;
            case POS24: // 自定义body输入框的响应
                showBodyEdit();
                break;
            case POS25: // 密码输入框
                showConfirmPassword();
                break;
            default:
                break;
        }
    }

    /**
     * 广告左上有x
     */
    private void showAdTopX() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog_ad_left_x, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        Component root = holder.getView(ResourceTable.Id_rootView);
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                root.createAnimatorProperty().moveFromY(-MOVE_Y).moveToY(0)
                                        .setDuration(DURATION2).start();
                            }
                        }, DELAY);

                        PageSlider pageSlider = holder.getView(ResourceTable.Id_pageSlider);
                        PageSliderIndicator indicator = holder.getView(ResourceTable.Id_indicator);
                        AdPageProvider provider = new AdPageProvider(getImagesLeft());
                        pageSlider.setProvider(provider);
                        indicatorConfig(indicator);
                        indicator.setPageSlider(pageSlider);
                        pageSlider.setClickedListener(component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this,
                                    "点击了第" + (pageSlider.getCurrentPage() + 1) + "页");
                            dia.hide();
                        });

                        holder.setOnClickListener(ResourceTable.Id_close, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rootView, component1 -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 广告下有x
     */
    private void showAdBottomX() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog_ad_bottom_x, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        Component root = holder.getView(ResourceTable.Id_rootView);
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                root.createAnimatorProperty().moveFromY(-MOVE_Y).moveToY(0)
                                        .setDuration(DURATION2).start();
                            }
                        }, DELAY);
                        PageSlider pageSlider = holder.getView(ResourceTable.Id_pageSlider);
                        AdPageProvider provider = new AdPageProvider(getImagesBottom());
                        pageSlider.setProvider(provider);
                        pageSlider.setClickedListener(component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this, "点击了" + (pageSlider.getCurrentPage() + 1));
                            dia.hide();
                        });

                        holder.setOnClickListener(ResourceTable.Id_close, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rootView, component1 -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 广告无X
     */
    private void showAdwithoutX() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog_ad, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        PageSlider pageSlider = holder.getView(ResourceTable.Id_pageSlider);
                        AdPageProvider provider = new AdPageProvider(getImages());
                        pageSlider.setProvider(provider);
                        pageSlider.setClickedListener(component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this, "点击了");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_close, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rootView, component1 -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 三个按钮
     */
    private void showThreeButtonDialog() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog12, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this, "取消");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textCenter, component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this, "中间");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textRight, component1 -> {
                            ToastUtils.showBottomToast(MainAbility.this, "确定");
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 倒计时
     */
    private void showCountDownDialog() {
        final int[] total3 = {30};
        final ViewHolder[] holders3 = new ViewHolder[1];
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog11, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holders3[0] = holder;
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textSure, component1 -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();

        Component textOk = holders3[0].getView(ResourceTable.Id_textSure);
        IntervalTimer intervalTime = new IntervalTimer(TOTAL_INTERVAL * INTERVAL, INTERVAL) {
            @Override
            public void onInterval(long l) {
                total3[0]--;
                runUi(() -> {
                    textOk.setEnabled(false);
                    ((Text) holders3[0].getView(ResourceTable.Id_textSure)).setText("确定(" + total3[0] + ")");
                    ((Text) holders3[0].getView(ResourceTable.Id_textSure))
                            .setTextColor(new Color(Color.getIntColor("#898D8B")));
                });
            }

            @Override
            public void onFinish() {
                runUi(() -> {
                    textOk.setEnabled(true);
                    ((Text) holders3[0].getView(ResourceTable.Id_textSure)).setText("确定");
                    ((Text) holders3[0].getView(ResourceTable.Id_textSure))
                            .setTextColor(new Color(Color.getIntColor("#007AFF")));
                });
            }
        };
        intervalTime.schedule();
    }

    /**
     * 自定义dialog
     */
    private void showDiyDialog() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog10, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        TextField editUser = holder.getView(ResourceTable.Id_fieldUser);

                        ShapeElement shapeElement1 = new ShapeElement();
                        shapeElement1.setRgbColor(new RgbColor(RED, GREEN, BLUE));
                        ShapeElement shapeElement2 = new ShapeElement();
                        shapeElement2.setRgbColor(new RgbColor(RGB, RGB, RGB));
                        editUser.setFocusChangedListener(new Component.FocusChangedListener() {
                            @Override
                            public void onFocusChange(Component component, boolean isFocus) {
                                if (isFocus) {
                                    editUser.setBasement(shapeElement1);
                                    editUser.setCursorElement(shapeElement1);
                                } else {
                                    editUser.setBasement(shapeElement2);
                                    editUser.setCursorElement(shapeElement2);
                                }
                            }
                        });
                        TextField editPassword = holder.getView(ResourceTable.Id_fieldPassword);
                        editPassword.setFocusChangedListener(new Component.FocusChangedListener() {
                            @Override
                            public void onFocusChange(Component component, boolean isFocus) {
                                if (isFocus) {
                                    editPassword.setBasement(shapeElement1);
                                    editPassword.setCursorElement(shapeElement1);
                                } else {
                                    editPassword.setBasement(shapeElement2);
                                    editPassword.setCursorElement(shapeElement2);
                                }
                            }
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 动态改变框
     */
    private void showDynamicDialog() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog9, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                holder.getView(ResourceTable.Id_rootView).createAnimatorProperty()
                                        .setCurveType(Animator.CurveType.DECELERATE)
                                        .moveByX(MOVE_X)
                                        .setDuration(DURATION4)
                                        .setLoopedCount(LOOPED_COUNT)
                                        .start();
                                ((Text) holder.getView(ResourceTable.Id_title)).setText("标题也变了");
                                ((Text) holder.getView(ResourceTable.Id_subTitle)).setText("小标题也变了");
                                ((Text) holder.getView(ResourceTable.Id_textSure)).setText("已经更新内容");
                            }
                        }, DELAY_TIME);
                    }
                })
                .setGravity(ConstandCodes.TOP)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 重试等待框
     */
    private void showRewaitingDialog() {
        final int[] total = {10};
        final ViewHolder[] holders2 = new ViewHolder[1];
        reWaiting(holders2);
        Component textSure = holders2[0].getView(ResourceTable.Id_textSure);
        IntervalTimer intervalTimer = new IntervalTimer(TOTAL_TIME * INTERVAL, INTERVAL) {
            @Override
            public void onInterval(long l) {
                total[0]--;
                runUi(() -> {
                    textSure.setEnabled(false);
                    holders2[0].getView(ResourceTable.Id_loading).setVisibility(Component.VISIBLE);
                    holders2[0].setText(ResourceTable.Id_textTips, "正在发送...");
                    holders2[0].setText(ResourceTable.Id_textSure, "再来(" + total[0] + ")");
                    holders2[0].setTextColor(ResourceTable.Id_textSure, new Color(Color.getIntColor("#8B8F8D")));
                });
            }

            @Override
            public void onFinish() {
                runUi(() -> {
                    total[0] = TOTAL_TIME;
                    textSure.setEnabled(true);
                    holders2[0].getView(ResourceTable.Id_loading).setVisibility(Component.INVISIBLE);
                    holders2[0].setText(ResourceTable.Id_textTips, "超时啦！请重试");
                    holders2[0].setText(ResourceTable.Id_textSure, "重试");
                    holders2[0].setTextColor(ResourceTable.Id_textSure, new Color(Color.getIntColor("#007AFF")));
                    ToastUtils.showBottomToast(MainAbility.this, "onTimerFinish");
                });
            }
        };
        intervalTimer.schedule();
        textSure.setClickedListener(component1 -> {
            ToastUtils.showBottomToast(MainAbility.this, "点了重试");
            intervalTimer.schedule();
        });
    }

    private void reWaiting(ViewHolder[] holders2) {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog8, ConstandCodes.COMMONTYPE)
                .setViewConvertListener((holder, dia) -> {
                    holders2[0] = holder;
                    EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                    eventHandler.postTask(new Runnable() {
                        @Override
                        public void run() {
                            holder.getView(ResourceTable.Id_loading).createAnimatorProperty()
                                    .rotate(ROTATE).setLoopedCount(INFINITE)
                                    .setDuration(DURATION3).start();
                        }
                    }, DELAY);
                    holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                        dia.hide();
                    });
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 等待框
     */
    private void showWaittingDialog() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog7, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                holder.getView(ResourceTable.Id_round_progress_bar).createAnimatorProperty()
                                        .rotate(ROTATE).setLoopedCount(INFINITE)
                                        .setDuration(DURATION3).start();
                            }
                        }, DELAY);
                        holder.setOnClickListener(ResourceTable.Id_close, component1 -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 进度框
     */
    private void showProgressDialog() {
        Timer timer = new Timer();
        final int max = 222;
        final int[] progress = {0};
        final ViewHolder[] holders = new ViewHolder[1];
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog6, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holders[0] = holder;
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                            dia.hide();
                            timer.cancel();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();

        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                progress[0]++;
                runUi(() -> {
                    if (progress[0] >= max) {
                        ((Text) holders[0].getView(ResourceTable.Id_textProgress)).setText("下载完成");
                        timer.cancel();
                    } else {
                        ((ProgressBar) holders[0].getView(ResourceTable.Id_progressBar)).setProgressValue(progress[0]);
                        ((ProgressBar) holders[0].getView(ResourceTable.Id_progressBar))
                                .setViceProgress(progress[0] + VICE_PROGRESS);
                        ((Text) holders[0].getView(ResourceTable.Id_textProgress))
                                .setText("已经下载" + (int) ((float) progress[0] / (float) max * PERCENT) + "%");
                    }
                });
            }
        };
        timer.schedule(task, 0, DELAY);
    }

    /**
     * 输入框
     */
    private void showInputDialog() {
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog5, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        TextField textField = holder.getView(ResourceTable.Id_textField);
                        Component tipsTxt = holder.getView(ResourceTable.Id_tipsTxt);
                        textField.addTextObserver(new Text.TextObserver() {
                            @Override
                            public void onTextUpdated(String text, int start, int before, int count) {
                                holder.setText(ResourceTable.Id_textCount, (LENGTH - text.length()) + "");
                                if (!text.isEmpty()) {
                                    tipsTxt.setVisibility(Component.HIDE);
                                }
                            }
                        });
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                        });
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textSure, component1 -> {
                            if (textField.getText().isEmpty()) {
                                tipsTxt.setVisibility(Component.VISIBLE);
                                return;
                            }
                            dia.hide();
                            ToastUtils.showBottomToast(MainAbility.this, textField.getText().toString());
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
    }

    /**
     * 换头像
     */
    private void showPortraitDialog() {
        final ViewHolder[] holders = new ViewHolder[1];
        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog4, ConstandCodes.COMMONTYPE)
                .setViewConvertListener((holder, dia) -> {
                    holders[0] = holder;
                    Component root = holder.getView(ResourceTable.Id_rootView);
                    eventHandler.postTask(() ->
                            root.createAnimatorProperty().scaleYFrom(0).scaleY(1).setDuration(DURATION).start(), DELAY);
                    holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                        root.createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
                        eventHandler.postTask(() -> dia.hide(), DURATION);
                    });
                    holder.setOnClickListener(ResourceTable.Id_textSure, component1 -> {
                        root.createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
                        eventHandler.postTask(() -> dia.hide(), DURATION);
                        ToastUtils.showBottomToast(MainAbility.this, "确定0");
                    });
                    holder.setOnClickListener(ResourceTable.Id_option1, component1 -> {
                        root.createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
                        eventHandler.postTask(() -> dia.hide(), DURATION);
                        ToastUtils.showBottomToast(MainAbility.this, "点击了：拍照");
                    });
                    holder.setOnClickListener(ResourceTable.Id_option2, component1 -> {
                        root.createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
                        eventHandler.postTask(() -> dia.hide(), DURATION);
                        ToastUtils.showBottomToast(MainAbility.this, "点击了：从相册选择");
                    });
                    holder.setOnClickListener(ResourceTable.Id_option3, component1 -> {
                        root.createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
                        eventHandler.postTask(() -> dia.hide(), DURATION);
                        ToastUtils.showBottomToast(MainAbility.this, "点击了：小视频");
                    });
                })
                .setGravity(ConstandCodes.BOTTOM).setCanceledOnTouchOutside(true).setTransparent(true);
        dialog.show();
        dialog.setDialogListener(() -> {
            holders[0].getView(ResourceTable.Id_rootView)
                    .createAnimatorProperty().scaleYFrom(1).scaleY(0).setDuration(DURATION).start();
            eventHandler.postTask(new Runnable() {
                @Override
                public void run() {
                    dialog.hide();
                }
            }, DURATION);
            return true;
        });
    }

    /**
     * 确认框
     */
    private void showIdentificationDialog() {
        BaseCircleDialog dialogs = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog3, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        ((Text) holder.getView(ResourceTable.Id_content))
                                .setText(getString(ResourceTable.String_long_introduce));

                        new EventHandler(EventRunner.getMainEventRunner()).postTask(new Runnable() {
                            @Override
                            public void run() {
                                holder.getView(ResourceTable.Id_content).scrollTo(0, 0);
                            }
                        }, DELAY);

                        holder.setOnClickListener(ResourceTable.Id_textCancel, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_close, component1 -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textSure, component1 -> {
                            dia.hide();
                            ToastUtils.showBottomToast(MainAbility.this, "确定0");
                        });
                    }
                })
                .setGravity(LayoutAlignment.CENTER)
                .setCanceledOnTouchOutside(true);
        dialogs.setTransparent(true);
        dialogs.setCancelable(false);
        dialogs.show();
    }

    /**
     * 提示框
     */
    private void showTipsDialog() {
        final boolean[] isShow = {false};
        dialog = BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_dialog2, ConstandCodes.CENTER)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setOnClickListener(ResourceTable.Id_textSure, new Component.ClickedListener() {
                            @Override
                            public void onClick(Component component) {
                                dia.hide();
                                ToastUtils.showBottomToast(MainAbility.this, "取消了!");
                            }
                        });
                    }
                })
                .setGravity(LayoutAlignment.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true);
        dialog.show();
        ToastUtils.showBottomToast(MainAbility.this, "显示了!");
        dialog.setDialogListener(new BaseDialog.DialogListener() {
            @Override
            public boolean isTouchOutside() {
                if (!isShow[0]) {
                    ToastUtils.showBottomToast(MainAbility.this, "取消了!");
                    dialog.hide();
                    isShow[0] = true;
                }
                return true;
            }
        });
    }

    /**
     * 列表单选、多选
     *
     * @param isMany 是否是多选
     */
    private void showRvListMulChoose(boolean isMany) {
        List<ListCheckEntry> entries = new ArrayList<>();
        for (int in = 0; in < LIST_SIZE; in++) {
            entries.add(new ListCheckEntry("item" + in, false));
        }
        RvListChooseProvider provider = new RvListChooseProvider(entries, getContext());
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_rv_list_choose, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_rv_list_choose_title, "自定义复选adapter");
                        String titleName = "单选";
                        if (isMany) {
                            titleName = "可多选";
                        }
                        holder.setText(ResourceTable.Id_rv_list_choose_secend_title, titleName);
                        holder.setOnItemClickListener(ResourceTable.Id_rv_list_choose_list, provider,
                                (listContainer, component, i, l) ->
                                        provider.setChoose(isMany, i));
                        holder.setOnClickListener(ResourceTable.Id_textCancel, component -> {
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_textSure, component -> {
                            String showText = "";
                            if (isMany) {
                                showText = provider.getChooseMany();
                                if (showText.isEmpty()) {
                                    ToastUtils.showBottomToast(getContext(), "请选择");
                                    return;
                                }
                            } else {
                                showText = provider.getChooseOne();
                            }
                            ToastUtils.showBottomToast(getContext(), showText);
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.CENTER)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * 列表单选、多选
     *
     * @param isMany 是否是多选
     */
    private void showRvListSingleChoose(boolean isMany) {
        List<ListCheckEntry> entries = new ArrayList<>();
        for (int in = 0; in < LIST_SIZE2; in++) {
            entries.add(new ListCheckEntry("item" + in, false));
        }
        RvListChooseProvider provider = new RvListChooseProvider(entries, getContext());
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_rv_list_choose2, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_rv_list_choose_title, "带复选的ListView");
                        String titleName = "单选";
                        if (isMany) {
                            titleName = "可多选";
                        }

                        Component root = holder.getView(ResourceTable.Id_rootView);
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                root.createAnimatorProperty().moveFromY(-MOVE_Y).moveToY(0)
                                        .setDuration(DURATION2).start();
                            }
                        }, DELAY);
                        holder.setText(ResourceTable.Id_rv_list_choose_secend_title, titleName);
                        holder.setOnItemClickListener(ResourceTable.Id_rv_list_choose_list, provider,
                                (listContainer, component, i, l) ->
                                        provider.setChoose(isMany, i));
                        holder.setOnClickListener(ResourceTable.Id_btn_enter, component -> {
                            String showText = "";
                            if (isMany) {
                                showText = provider.getChooseMany();
                            } else {
                                showText = provider.getChooseOne();
                            }
                            ToastUtils.showBottomToast(getContext(), "选择了：" + showText);
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.BOTTOM)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * 自定义内容视图
     */
    private void showContentImg() {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_rv_content_img, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_rv_content_img_title, "提示");
                        holder.setOnClickListener(ResourceTable.Id_dl_cancel, new Component.ClickedListener() {
                            @Override
                            public void onClick(Component component) {
                                dia.hide();
                            }
                        });
                    }
                })
                .setGravity(ConstandCodes.CONFRIMTYPE)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * 显示lottie动画框
     */
    private void showLottieAnimator() {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_lottie, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        L.setTraceEnabled(true);
                        LottieAnimationViewData data = new LottieAnimationViewData();
                        data.setFilename("loading.json");
                        data.setRepeatCount(REPEAT_COUNT);
                        data.autoPlay = true;
                        LottieAnimationView lottieAnimationView = holder.getView(ResourceTable.Id_lottie_ani);
                        lottieAnimationView.setAnimationData(data);
                    }
                })
                .setGravity(ConstandCodes.CONFRIMTYPE)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * 微博分享
     */
    private void showWeiboShare() {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_share, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setOnClickListener(ResourceTable.Id_circle, component -> {
                            ToastUtils.showBottomToast(getContext(), "朋友圈");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_wechat, component -> {
                            ToastUtils.showBottomToast(getContext(), "微信");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_weibo, component -> {
                            ToastUtils.showBottomToast(getContext(), "微博");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_qq, component -> {
                            ToastUtils.showBottomToast(getContext(), "QQ");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_qqzone, component -> {
                            ToastUtils.showBottomToast(getContext(), "QQ空间");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_share, component -> {
                            ToastUtils.showBottomToast(getContext(), "分享");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_delete, component -> {
                            ToastUtils.showBottomToast(getContext(), "删除");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_add, component -> {
                            ToastUtils.showBottomToast(getContext(), "添加");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_github, component -> {
                            ToastUtils.showBottomToast(getContext(), "Github位置");
                            dia.hide();
                        });
                    }
                })
                .setCanceledOnTouchOutside(true)
                .setGravity(ConstandCodes.BOTTOM)
                .setTransparent(true)
                .show();
    }

    /**
     * 列表展示
     *
     * @param isVertical 是否是纵向
     */
    private void showList(boolean isVertical) {
        int resourceId = ResourceTable.Layout_layout_list_vertical;
        if (!isVertical) {
            resourceId = ResourceTable.Layout_layout_list_horizontal;
        }
        List<String> listName = new ArrayList<>();
        listName.add("拍照");
        listName.add("从相册选择");
        listName.add("小视频");
        listName.add("拍照1");
        listName.add("从相册选择1");
        listName.add("小视频1");
        listName.add("拍照2");
        listName.add("从相册选择3");
        listName.add("小视频4");
        BaseCircleDialog.init(getContext())
                .setLayoutId(resourceId, ConstandCodes.COMMONTYPE)
                .setViewConvertListener((holder, dia) -> {
                    ListContainer list = holder.getView(ResourceTable.Id_rv_list);
                    if (!isVertical) {
                        list.setOrientation(Component.HORIZONTAL);
                        holder.getView(ResourceTable.Id_layout_list_horizontal_title)
                                .setVisibility(Component.VISIBLE);
                        holder.getView(ResourceTable.Id_layout_list_horizontal_line)
                                .setVisibility(Component.VISIBLE);
                    } else {
                        Component root = holder.getView(ResourceTable.Id_rootView);
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                root.createAnimatorProperty().moveFromY(-MOVE_Y).moveToY(0)
                                        .setDuration(DURATION2).start();
                            }
                        }, DELAY);
                    }
                    holder.setOnItemClickListener(ResourceTable.Id_rv_list,
                            new RvListProvider(listName, getContext(), isVertical), (lc, com, i, l) -> {
                                ToastUtils.showBottomToast(getContext(), listName.get(i));
                                dia.hide();
                            });
                    holder.setOnClickListener(ResourceTable.Id_dl_cancel, component -> dia.hide());
                })
                .setCanceledOnTouchOutside(true)
                .setGravity(ConstandCodes.BOTTOM)
                .setTransparent(true)
                .show();
    }

    /**
     * 自定义body输入框的响应
     */
    private void showBodyEdit() {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_body_edit, ConstandCodes.COMMONTYPE)
                .setViewConvertListener((holder, dia) -> {
                    TextField editUser = holder.getView(ResourceTable.Id_body_edit1);
                    TextField editPassword = holder.getView(ResourceTable.Id_body_edit2);
                    ShapeElement shapeElement1 = new ShapeElement();
                    shapeElement1.setRgbColor(new RgbColor(RED, GREEN, BLUE));
                    ShapeElement shapeElement2 = new ShapeElement();
                    shapeElement2.setRgbColor(new RgbColor(RGB, RGB, RGB));
                    Text loginTxt = holder.getView(ResourceTable.Id_dl_enter);
                    editStatus(editUser, editPassword, shapeElement1, shapeElement2);
                    editUser.addTextObserver((str, i, i1, i2) -> {
                        if (str.length() > 0 && editPassword.getText().length() > 0) {
                            loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_blue)));
                        } else {
                            loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_gray)));
                        }
                    });
                    editPassword.addTextObserver((str, i, i1, i2) -> {
                        if (str.length() > 0 && editUser.getText().length() > 0) {
                            loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_blue)));
                        } else {
                            loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_gray)));
                        }
                    });
                    holder.setText(ResourceTable.Id_body_edit_title, "自定义body");
                    holder.setText(ResourceTable.Id_body_edit_title2, "按钮回调view");
                    holder.setOnClickListener(ResourceTable.Id_dl_cancel, component -> dia.hide());
                    holder.setOnClickListener(ResourceTable.Id_dl_enter, component -> {
                        TextField name = holder.getView(ResourceTable.Id_body_edit1);
                        TextField pass = holder.getView(ResourceTable.Id_body_edit2);
                        if (name.getText().isEmpty() || pass.getText().isEmpty()) {
                            return;
                        }
                        if ("1".equals(name.getText()) && "2".equals(pass.getText())) {
                            dia.hide();
                        } else {
                            holder.setText(ResourceTable.Id_body_edit_tips, "用户名或密码错误");
                        }
                    });
                })
                .setGravity(ConstandCodes.CONFRIMTYPE)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    private void editStatus(TextField editUser, TextField editPassword, ShapeElement shapeElement1,
                            ShapeElement shapeElement2) {
        editUser.setFocusChangedListener((component, b) -> {
            if (b) {
                editUser.setBasement(shapeElement1);
                editUser.setCursorElement(shapeElement1);
            } else {
                editUser.setBasement(shapeElement2);
                editUser.setCursorElement(shapeElement2);
            }
        });
        editPassword.setFocusChangedListener((component, b) -> {
            if (b) {
                editPassword.setBasement(shapeElement1);
                editPassword.setCursorElement(shapeElement1);
            } else {
                editPassword.setBasement(shapeElement2);
                editPassword.setCursorElement(shapeElement2);
            }
        });
    }

    /**
     * 确认密码框
     */
    private void showConfirmPassword() {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_confirm_password, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_confirm_password_title, "设置密码");
                        holder.setText(ResourceTable.Id_confirm_password_title2, "请您牢记此密码");
                        ShapeElement shapeElement1 = new ShapeElement();
                        shapeElement1.setRgbColor(new RgbColor(RED, GREEN, BLUE));
                        TextField edit1 = holder.getView(ResourceTable.Id_confirm_password_edit1);
                        TextField edit2 = holder.getView(ResourceTable.Id_confirm_password_edit2);
                        edit1.setCursorElement(shapeElement1);
                        edit2.setCursorElement(shapeElement1);
                        Text loginTxt = holder.getView(ResourceTable.Id_dl_enter);
                        holder.setOnClickListener(ResourceTable.Id_dl_cancel, component -> dia.hide());
                        edit1.addTextObserver((str, i, i1, i2) -> {
                            if (str.length() > 0 && edit2.getText().length() > 0) {
                                loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_blue)));
                            } else {
                                loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_gray)));
                            }
                        });
                        edit2.addTextObserver((str, i, i1, i2) -> {
                            if (str.length() > 0 && edit1.getText().length() > 0) {
                                loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_blue)));
                            } else {
                                loginTxt.setTextColor(new Color(getColor(ResourceTable.Color_gray)));
                            }
                        });
                        holder.setOnClickListener(ResourceTable.Id_dl_enter, component -> {
                            TextField name = holder.getView(ResourceTable.Id_confirm_password_edit1);
                            TextField pass = holder.getView(ResourceTable.Id_confirm_password_edit2);
                            if (name.getText().isEmpty() || pass.getText().isEmpty()) {
                                return;
                            }
                            if (!name.getText().equals(pass.getText().isEmpty())) {
                                holder.setText(ResourceTable.Id_confirm_password_tips, "两次密码不一致");
                            } else {
                                dia.hide();
                            }
                        });
                    }
                })
                .setGravity(ConstandCodes.CONFRIMTYPE)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    private List<Integer> getImages() {
        List<Integer> list = new ArrayList<>();
        list.add(ResourceTable.Media_ic_zfbxcc);
        return list;
    }

    private List<Integer> getImagesBottom() {
        List<Integer> list = new ArrayList<>();
        list.add(ResourceTable.Media_ad1);
        list.add(ResourceTable.Media_ad2);
        list.add(ResourceTable.Media_ad3);
        return list;
    }

    private List<Integer> getImagesLeft() {
        List<Integer> list = new ArrayList<>();
        list.add(ResourceTable.Media_ad4);
        list.add(ResourceTable.Media_ad1);
        list.add(ResourceTable.Media_ad2);
        list.add(ResourceTable.Media_ad3);
        return list;
    }

    private void indicatorConfig(PageSliderIndicator indicator) {
        ShapeElement normalElement = new ShapeElement(this, ResourceTable.Graphic_unselected_page_bg_element);
        ShapeElement selectedElement = new ShapeElement(this, ResourceTable.Graphic_selected_page_bg_element);
        indicator.setItemElement(normalElement, selectedElement);
        indicator.setItemOffset(OFFSET);
    }

    /**
     * Rv换头像
     *
     * @param title 标题
     * @param content 副标题
     */
    private void showRvImage(String title, String content) {
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_rv_image, ConstandCodes.COMMONTYPE)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_rv_image_title, title);
                        holder.setText(ResourceTable.Id_rv_image_secend_title, content);
                        holder.setOnClickListener(ResourceTable.Id_rv_image_item1, component -> {
                            ToastUtils.showBottomToast(getContext(), "点击了：拍照");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rv_image_item2, component -> {
                            ToastUtils.showBottomToast(getContext(), "点击了：从相册选择");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rv_image_item3, component -> {
                            ToastUtils.showBottomToast(getContext(), "点击了：小视频");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rv_image_item4, component -> {
                            ToastUtils.showBottomToast(getContext(), "点击了：拍照1");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_rv_image_item5, component -> {
                            ToastUtils.showBottomToast(getContext(), "点击了：从相册选择1");
                            dia.hide();
                        });
                        holder.setOnClickListener(ResourceTable.Id_dl_cancel, component -> {
                            dia.hide();
                        });
                    }
                })
                .setGravity(ConstandCodes.BOTTOM)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * RvAdapter
     */
    private void showRvAdapter() {
        List<String> list = new ArrayList<>();
        list.add("Head1:");
        list.add("Head1:0");
        list.add("Head1:1");
        list.add("Head1:2");
        list.add("Head1:3");
        list.add("Head2:");
        list.add("Head2:0");
        list.add("Head2:1");
        list.add("Head2:2");
        list.add("Head2:3");
        list.add("Head2:4");
        list.add("Head2:5");
        BaseCircleDialog.init(getContext())
                .setLayoutId(ResourceTable.Layout_layout_rv_adapter, ConstandCodes.CENTER)
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, BaseCircleDialog dia) {
                        holder.setText(ResourceTable.Id_rv_adapter_title, "rvAdapter");
                        holder.setText(ResourceTable.Id_rv_adapter_secend_title, "副标题哦!");

                        Component root = holder.getView(ResourceTable.Id_rootView);
                        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
                        eventHandler.postTask(new Runnable() {
                            @Override
                            public void run() {
                                root.createAnimatorProperty().moveFromY(-MOVE_Y).moveToY(0)
                                        .setDuration(DURATION2).start();
                            }
                        }, DELAY);
                        holder.setOnItemClickListener(ResourceTable.Id_rv_adapter_list,
                                new RvAdapterProvider(list, getContext()), (listContainer, component, i, l) -> {
                                    dia.hide();
                                    ToastUtils.showBottomToast(getContext(),
                                            "点击的是：com.mylhyl.circledialog.samplese.entities.MySectionEntity@" + i);
                                });
                    }
                })
                .setGravity(ConstandCodes.BOTTOM)
                .setCanceledOnTouchOutside(true)
                .setTransparent(true)
                .show();
    }

    /**
     * toast固定文字
     *
     * @param content 内容
     */
    private void toastShowText(String content) {
        DirectionalLayout toastLayout = (DirectionalLayout) LayoutScatter.getInstance(this)
                .parse(ResourceTable.Layout_layout_toast, null, false);
        showToast = (Text) toastLayout.findComponentById(ResourceTable.Id_msg_toast);
        toast = new ToastDialog(getContext());
        toast.setContentCustomComponent(toastLayout);
        toast.setSize(DirectionalLayout.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT);
        toast.setAlignment(LayoutAlignment.CENTER);
        showToast.setText(content);
        toast.show();
    }

    /**
     * 启动ability
     *
     * @param ability ability
     * @param name name
     */
    public void startAbility(Ability ability, String name) {
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withDeviceId("")
                .withBundleName(ability.getBundleName())
                .withAbilityName(name)
                .build();
        intent.setOperation(operation);
        ability.startAbility(intent);
    }

    /**
     * 主线程执行任务
     *
     * @param runnable runnable
     */
    public static void runUi(Runnable runnable) {
        EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
        eventHandler.postSyncTask(runnable);
    }
}
